package ziface

import (
	"time"

	"github.com/xtaci/kcp-go/v5"
)

// kcp client
type IKcpClient interface {
	AddRouter(msgID uint32, router IRouter)

	SetOnConnStart(func(IConnection))

	SetOnConnStop(func(IConnection))

	GetOnConnStart() func(IConnection)

	GetOnConnStop() func(IConnection)

	GetPacket() IDataPack

	SetPacket(IDataPack)

	GetMsgHandler() IMsgHandle

	StartHeartBeat(time.Duration)

	SetDecoder(IDecoder)

	AddInterceptor(IInterceptor)

	GetLengthField() *LengthField

	GetErrChan() chan error

	// 尝试连接服务器, 这里设置阻塞函数, 5秒超时报错
	// 返回客户端Id
	Connect(timeout int) (connId uint64, err error)

	// 发送数据
	SendMsg(connId uint64, msgId uint32, b []byte) error

	StartConn(conn IConnection)

	Close(connId uint64)

	Connect2() (*kcp.UDPSession, error)
}
